package xyz.eden.cloud.common.web.support.domain.ability;


import xyz.eden.cloud.common.core.exception.ParameterException;
import xyz.eden.cloud.common.core.util.AssertUtils;
import xyz.eden.cloud.common.web.support.domain.ability.model.BaseOperate;
import xyz.eden.cloud.common.web.support.domain.ability.model.OperatorInfo;
import xyz.eden.cloud.common.web.support.domain.gateway.BaseOperateGateway;

public interface BaseOperateDomainService<Model extends BaseOperate,
        OperateGateway extends BaseOperateGateway<Model>> {

    default Long addInfo(Model model) throws Exception {
        BaseOperateGateway<Model> operateGateway = this.getOperateGateway();
        return operateGateway.addInfo(model);
    }

    default Boolean verifyAddInfo(Model model) throws Exception {
        AssertUtils.notNull(model, new ParameterException("add info is null"));
        OperatorInfo operatorInfo = model.getOperatorInfo();
        AssertUtils.notNull(operatorInfo, new ParameterException("Operator info is null"));
        return true;
    }

    OperateGateway getOperateGateway();
}
